home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
Xprof
/
xprof
/
error.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
4KB
|
118 lines
/*==================================================================
* File : error.c
* Package: Xprof
*
* Author : Aloke Gupta.
*
* (C) Copyright 1992, Aloke Gupta.
*==================================================================*/
/*
* Processing routines for the errors seen in the message stream.
* Functions:
* 1. process_error(FILE *fp, char *string, GlobalStats *gstats)
* 2. print_error_stats(FILE *fp)
* 3. The routines to process each error seen. These have the format:
* Error(FILE *fp, error_index, current_time)
*/
#include <stdio.h>
#include "common.h"
MsgStats TotalErrorStats; /* Overall stats for all errors */
MsgStats ErrorStats[MAXERRORS]; /* Detailed stats for each error */
/*static char in_string[MAXSTRINGSIZE];*/ /* Buffer to read a record into */
static char sbuf[132]; /* Temp. slots for sscanf*/
extern MsgType ErrorType[];
extern int lookup_error();
process_error(fp, string, gstats)
FILE *fp;
char *string;
GlobalStats *gstats;
{
char error_name[80]; /* Name of the current error */
int error_index; /* Index in the data structures */
long bytes=0; /* number of bytes */
if (TotalErrorStats.invoked == FALSE)
InitMsgStats(&TotalErrorStats, gstats->current_time, DETAILED, GRAIN1);
sscanf(string, "%s %s",sbuf, error_name);
error_index = lookup_error(error_name);
/* Call the action for this error */
bytes=ErrorType[error_index].action(fp, error_index, gstats->current_time);
/*
* Fill the data structures for all the errors.
*/
FillMsgStats(&TotalErrorStats, gstats->current_time, bytes, bytes);
gstats->error_bytes += bytes;
}
print_error_stats(fp)
FILE *fp;
{
int i;
char *dashes = "---------------------------------------------------------------" ;
if (TotalErrorStats.invoked == FALSE)
return;
/*
* Print the details for all Errors together
*/
PrintMsgStats(fp, &TotalErrorStats, "ERRORS ");
/*
* Brief table for the numbers and byte totals for the errors
*/
fprintf(fp,"\t%s\n", dashes);
fprintf(fp,"%-25s", " ERROR messages");
fprintf(fp,"%25s", "Total Bytes ");
fprintf(fp," %19s\n","Number ");
fprintf(fp,"\t%s\n", dashes);
for (i = 0; i < MAXERRORS; i++)
if (ErrorStats[i].invoked == TRUE) {
fprintf(fp,"%-25s", ErrorType[i].name);
fprintf(fp," %10ld bytes",ErrorStats[i].total_bytes);
fprintf(fp," (%5.2f%%)", (float) 100 * ErrorStats[i].total_bytes /
TotalErrorStats.total_bytes);
fprintf(fp," %10ld", ErrorStats[i].number );
fprintf(fp," (%5.2f%%)", (float) 100 * ErrorStats[i].number /
TotalErrorStats.number);
fprintf(fp,"\n");
}
fprintf(fp,"\t%s\n", dashes);
fprintf(fp,"\t%s\n", dashes);
fprintf(fp,"%25s"," Grand Total ");
fprintf(fp," %10ld bytes ", TotalErrorStats.total_bytes);
fprintf(fp," %10ld \n", TotalErrorStats.number);
fprintf(fp,"\t%s\n", dashes);
fprintf(fp,"\t%s\n", dashes);
if (verboselevel > 0) {
for (i = 0; i < MAXERRORS; i++)
if (ErrorStats[i].detailed == DETAILED)
PrintMsgStats(fp, &ErrorStats[i], ErrorType[i].name);
}
/*
* Now dump the raw statistics for the messages
*/
if (verboselevel > 1) {
if (TotalErrorStats.detailed == DETAILED)
PrintMsgDetails(fp, &TotalErrorStats, "ERRORS ");
for (i = 0; i < MAXERRORS; i++)
if (ErrorStats[i].detailed == DETAILED)
PrintMsgDetails(fp, &ErrorStats[i], ErrorType[i].name);
}
return;
}